﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_GetBangdingStaff_V2]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_GetBangdingStaff_V2];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_GetBangdingStaff_V2]
    @FlowID int,
    @StepID int
AS
BEGIN
SET NOCOUNT ON;

SELECT
        s.staff_id,
        s.realName as Staff_Name,
        ISNULL
        (
            (
                SELECT TOP (1) 1
                FROM dbo.uds_flow_member_bind m
                WHERE
                    m.obj_id = s.staff_id
                    and m.obj_type = /* staff */ 4 
                    and m.flow_id = @FlowID
                    and m.step_id = @StepID
            ), 0
        ) as Bound
    FROM dbo.uds_staff s;

END
GO